import $ from 'jquery'

//设置是否是开发环境还是  线上环境  true 为测试环境
const develop =true;
//接口头部
const host = develop ? "https://testadmin.meckeeper.com/" : "https://wap.meckeeper.com/";
//个人信息图片的头部
const IMAGE_URL_HOST = develop ? "https://testadmin.meckeeper.com/upload/" :"https://wap.meckeeper.com/upload/";
const PIC_URL_HOST = develop ? "https://mec-test.oss-cn-beijing.aliyuncs.com/" : "https://mec-master.oss-cn-beijing.aliyuncs.com/";

//上传视频 用的react router 的basename路径
const PC_HOST=develop ? "/testadmin/pc/videoup" : "/wap/pc/videoup";
const url={
  host,PC_HOST,
  IMAGE_URL_HOST,
  PIC_URL_HOST,

  // mobile：手机号码  key ：动作: 31 登陆
  getCode: `${host}app/v1/appaction/sendmcode`,
  //登录
  smsLogin:`${host}app/v1/login/smsLogin`,
  //个人信息修改 
  changedetail:`${host}app/v1/user/edtNickName`,
  //上传
  upload:`${host}app/v1/live/saveVideo`,
  //退出
  logout:`${host}app/v1/login/logout`,
  //视频删除
  delInfo:`${host}app/v1/live/delVideo`,
  //获取秘钥
  getSign:`${host}app/v1/live/getSign`,
  //h5
  h5Video:`${host}app/v1/live/h5Video`
}
function sendRequest(url, data, callback) {
  $.ajax({
    url:url,
    data: {
      "jsondata": JSON.stringify(data)
    },
    contentType:'application/x-www-form-urlencoded',
    success:function(res){
      var result=JSON.parse(res)
      callback(result)
    },error:function(err){
      callback(err)
    }
  })
}

function getInfo(){
  return JSON.parse(sessionStorage.getItem("info"));
}

export default{
    url: url,
    getInfo,
    sendRequest: sendRequest,
}